home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
jpi
/
spriteed.bas
< prev
next >
Wrap
BASIC Source File
|
1998-01-04
|
11KB
|
402 lines
Attribute VB_Name = "Module1"
Global Const PICDEFFILE$ = "PictureDefs.Dat"
Global Const SPRITEDEFFILE$ = "Sprites.Dat"
Global Const CurrVers$ = "ION FORMAT VERSION: 1.0"
Type Spfs
FrameName As String
picname As String
Duration As Integer
End Type
Type SpfGs
GroupRepeats As Boolean
SpriteGroupName As String
SpriteFrames(100) As Spfs
FrameMax As Integer
End Type
Type Sps
SpriteName As String
SpriteFrameGroups(20) As SpfGs
GroupMax As Integer
End Type
Global Sprites(200) As Sps
Type pcz
Masked As Boolean
GraphicsLib As String
picname As String
X As Integer
Y As Integer
Width As Integer
Height As Integer
End Type
Global Picz(500) As pcz
Global PicMax As Integer
Global SpriteMax As Integer
Type Lbs
LibName As String
picname As String
End Type
Global GraphicLibs(100) As Lbs
Global LibMax As Integer
Sub LoadPicInfo()
On Error GoTo ERR1
PicMax = 0
Open PICDEFFILE$ For Input As #1
Line Input #1, a$
If a$ <> CurrVers$ Then
Call CurrVersError
End If
Do
Line Input #1, a$
If a$ = "[ENDOFFILE]" Then Exit Do
If a$ = "[PICDEF]" Then
'increments the current picture num
PicMax = PicMax + 1
'Picture name
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Picz(PicMax).picname = fval$
'Graphics Library of the pic
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Picz(PicMax).GraphicsLib = fval$
'X
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Picz(PicMax).X = Val(fval$)
'Y
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Picz(PicMax).Y = Val(fval$)
'Width
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Picz(PicMax).Width = Val(fval$)
'Height
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Picz(PicMax).Height = Val(fval$)
End If
Loop
Close #1
Exit Sub
ERR1:
Close #1
PicMax = 0
End Sub
Sub CurrVersError()
MsgBox "Wrong file version"
End
End Sub
Public Function GetPropertyValue(TextString) As String
GetPropertyValue = Right$(TextString, Len(TextString) - InStr(1, TextString, " "))
If InStr(1, TextString, " ") = 0 Then GetPropertyValue = ""
End Function
Sub LoadAll()
Call LoadPicInfo
Call LoadSpriteInfo
End Sub
Sub LoadSpriteInfo()
On Error GoTo ERR2
SpriteMax = 0
Open SPRITEDEFFILE$ For Input As #1
Line Input #1, a$
If a$ <> CurrVers$ Then
Call CurrVersError
End If
Do
Line Input #1, a$
If a$ = "[ENDOFFILE]" Then Exit Do
If a$ = "[SPRITEDEF]" Then
'increments the current sprite num
SpriteMax = SpriteMax + 1
'name of the sprite
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Sprites(SpriteMax).SpriteName = fval$
'reset the group number
Sprites(SpriteMax).GroupMax = 0
Do
Line Input #1, a$
If a$ = "[ENDSPRITEDEF]" Then Exit Do
If a$ = "-FRAMEGROUP-" Then
Sprites(SpriteMax).GroupMax = Sprites(SpriteMax).GroupMax + 1
'Group name
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteGroupName = fval$
'group Repeats
Line Input #1, a$
fval$ = GetPropertyValue(a$)
If fval$ = "True" Then
YesNo = True
Else
YesNo = False
End If
Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).GroupRepeats = YesNo
FrameMax = 0
Do
Line Input #1, a$
If a$ = "-ENDFRAMEGROUP-" Then Exit Do
If a$ = "-FRAME-" Then
FrameMax = FrameMax + 1
Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).FrameMax = FrameMax
'Frame name
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteFrames(FrameMax).FrameName = fval$
'Frame duration
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteFrames(FrameMax).Duration = Val(fval$)
'Frame picture name
Line Input #1, a$
fval$ = GetPropertyValue(a$)
Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteFrames(FrameMax).picname = fval$
End If
Loop
End If
Loop
End If
Loop
Close #1
Exit Sub
ERR2:
Close #1
SpriteMax = 0
End Sub
Sub updateSpritelist()
currindex = Form1.List1.ListIndex
Form1.List1.Clear
Form1.List1.AddItem "[NewSprite]"
For i = 1 To SpriteMax
Form1.List1.AddItem Sprites(i).SpriteName
Next i
Form1.List1.ListIndex = currindex
Form1.Label1.Caption = Form1.List1.List(Form1.List1.ListIndex)
End Sub
Sub UpdateSpriteProperties()
snum = Form1.List1.ListIndex
If snum > 0 Then
Form1.Text1.Text = Sprites(snum).SpriteName
Else
Form1.Text1.Text = ""
End If
Form1.Label1.Caption = Form1.List1.List(Form1.List1.ListIndex)
End Sub
Sub UpdateGroupProperties()
snum = Form1.List1.ListIndex
gnum = Form1.List2.ListIndex
If snum > 0 Then
Form1.Text2.Text = Sprites(snum).SpriteFrameGroups(gnum).SpriteGroupName
If Sprites(snum).SpriteFrameGroups(gnum).GroupRepeats = True Then
Form1.Check1.Value = 1
Else
Form1.Check1.Value = 0
End If
Else
Form1.Text2.Text = ""
Form1.Check1.Value = 0
End If
End Sub
Sub UpdateGroupList()
currindex = Form1.List2.ListIndex
Form1.List2.Clear
Form1.List2.AddItem "[NewGroup]"
snum = Form1.List1.ListIndex
For i = 1 To Sprites(snum).GroupMax
Form1.List2.AddItem Sprites(snum).SpriteFrameGroups(i).SpriteGroupName
Next i
Form1.List2.ListIndex = currindex
End Sub
Sub UpdateFrameList()
currindex = Form1.List3.ListIndex
Form1.List3.Clear
Form1.List3.AddItem "[NewFrame]"
snum = Form1.List1.ListIndex
gnum = Form1.List2.ListIndex
For i = 1 To Sprites(snum).SpriteFrameGroups(gnum).FrameMax
Form1.List3.AddItem Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(i).FrameName
Next i
Form1.List3.ListIndex = currindex
End Sub
Sub UpdateFrameProperties()
snum = Form1.List1.ListIndex
gnum = Form1.List2.ListIndex
fnum = Form1.List3.ListIndex
If snum > 0 Then
Form1.Text4.Text = Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(fnum).Duration
For i = 0 To Form1.List4.ListCount - 1
If Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(fnum).picname = Form1.List4.List(i) Then
Form1.List4.ListIndex = i
Exit For
End If
Next i
Form1.Text3.Text = Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(fnum).FrameName
Else
Form1.Text3.Text = ""
End If
End Sub
Sub updateSpritenamelist()
On Error Resume Next
Form1.List4.Clear
For i = 1 To PicMax
Form1.List4.AddItem Picz(i).picname
Next i
For i = 0 To PicMax - 1
If Form1.List4.List(i) = Sprites(Form1.List5.ListIndex).SpriteFrameGroups(Form1.List2.ListIndex).SpriteFrames(Form1.List3.ListIndex).picname Then
Form1.List4.ListIndex = i
Exit For
End If
Next i
End Sub
Sub LoadGraphicLibs()
On Error GoTo err
LibMax = 0
Open "GraphicLibs.Dat" For Input As #1
Line Input #1, a$
Do
Line Input #1, a$
If a$ = "[ENDOFFILE]" Then Exit Do
If a$ = "[GRAPHICSLIBRARYDEF]" Then
LibMax = LibMax + 1
Line Input #1, a$
fval$ = GetPropertyValue(a$)
GraphicLibs(LibMax).LibName = fval$
Line Input #1, a$
fval$ = GetPropertyValue(a$)
GraphicLibs(LibMax).picname = fval$
End If
Loop
Close #1
Exit Sub
err:
Close #1
Exit Sub
End Sub
Sub UpdatePicList()
CurrIndx = Form1.List5.ListIndex
Form1.List5.Clear
Form1.List5.AddItem "[NewPic]"
For i = 1 To PicMax
Form1.List5.AddItem Picz(i).picname
Next i
Form1.List5.ListIndex = CurrIndx
End Sub
Sub UpdateLibList()
On Error Resume Next
Fo